//
//  SKUDetailTbv_V4_enquiryPrice_Cell.m
//  ZITHER
//
//  Created by weixin on 2019/2/22.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "SKUDetailTbv_V4_enquiryPrice_Cell.h"

@implementation SKUDetailTbv_V4_enquiryPrice_Cell

- (void)awakeFromNib {
    [super awakeFromNib];
    
//    if ([Main_Token_Model_MANAGER.isToken isEqualToString:@"1"]) {
//        self.lab.hidden = YES;
//        self.labSub.hidden = YES;
//        self.openEnquiryPric.hidden = YES;
//    } else {
//        self.lab.hidden = NO;
//        self.labSub.hidden = NO;
//        self.openEnquiryPric.hidden = NO;
//    }
    // Initialization code
    [self addSubview:self.lab];
    [self addSubview:self.labSub];
    [self addSubview:self.openEnquiryPric];

    
    [self.lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.openEnquiryPric).offset(0);
        make.left.equalTo(self).offset(15);
        make.height.mas_equalTo(16);
    }];
    
    [self.labSub mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.openEnquiryPric.mas_bottom).offset(0);
        make.left.equalTo(self).offset(15);
        make.height.mas_equalTo(13);
    }];
    
    [self.openEnquiryPric mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(20);
        make.right.equalTo(self).offset(-15);
        make.width.mas_equalTo(120);

        make.height.mas_equalTo(40);
        make.bottom.equalTo(self).offset(-20);
    }];
}

-(BaseLab *)lab{
    if (!_lab) {
        _lab = [BaseLab initCustomLab:@"询价" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFangSC-Semibold" size:15.f]];
    }
    return _lab;
}

-(BaseLab *)labSub{
    if (!_labSub) {
        _labSub = [BaseLab initCustomLab:@"真实货源报价 在线比价" color:HexColor(0x333333) font:[UIFont fontWithName:@"PingFang-SC-Regular" size:12]];
    }
    return _labSub;
}

-(BaseBtn *)openEnquiryPric{
    if (!_openEnquiryPric) {
        _openEnquiryPric = [BaseBtn initCustomBtnTitlestype:@[@"开启询价"] color:@[[UIColor whiteColor]]];
        _openEnquiryPric.backgroundColor = baseColorTheme;
        [_openEnquiryPric setCornerRadiusWithRadius:4 isMasks:YES];
        
        @weakify(self);
        [[_openEnquiryPric rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            if (!kUSER_INFO_MANAGER.userIsLogin) {
                [Tools pushSinge];
                return ;
            }
            [[serviceDefualt loadopenEnquiry:self.model.goodsId]subscribeNext:^(ResponseData* x) {
                if (x.success) {
                    
                    if (self.openEnquiryPric.selected) {
                        [Tools showTips:@"重启询价成功"];
                        if (self.OpenQuestion) {
                            self.OpenQuestion();
                        }
                        
                    }else{
                        self.openEnquiryPric.selected = !self.openEnquiryPric.selected;
                        [Tools showTips:@"开启询价成功"];
                        if (self.OpenQuestion) {
                            self.OpenQuestion();
                        }
                        
                    }
                    
                }else{
                    [Tools showTips:x.errorInfo];
                }
            }];
        }];
    }
    return _openEnquiryPric;
}

@end
